package dm.ast.model.gen;

import dm.ast.DmASTNode;
import dm.ast.DmLimit;
import test.utility.Randomly;

/**
 * 根据模板AST生成Limit子句
 */
public class LimitGen extends ASTGenBase{
    static int limitmax = 1000;

    @Override
    public DmASTNode gen(int astLevel, int wid_t, int dep_t) {
        DmLimit limit = new DmLimit();
        int limitFormat = (int)Randomly.getNotCachedInteger(0, DmLimit.SUPPORT_FORMAT);
        limit.setFormat(limitFormat);
        limit.setM((int)Randomly.getNotCachedInteger(1 , limitmax));
        if(limitFormat != 0){
            limit.setN((int)Randomly.getNotCachedInteger(1 , limitmax));
        }
        limit.setWidt();
        limit.setDept();
        return limit;

    }
}
